#ifndef GDI703T_H
#define GDI703T_H

#define WINAPI
#define CALLBACK
#define THREAD_SLEEP(msec) usleep(msec * 1000)
#define ASSERT(x)
#define AMSG(x) ((x) ? "有" : "无")

#include <stdio.h>
#include <stdlib.h>

#include <time.h>
#include <pthread.h>

#include "win_types.h"
#include "cts_sdk.h"

#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"

#include "pipe_communicate.h"

typedef struct
{
	enSdkDevState eState;
	BYTE AlmInState;  // 报警输入通道状态指示码，每位对应一路报警: 0(无报警), 1(有报警)。
	BYTE AlmOutState; // 报警输出通道状态指示码，每位对应一路报警: 0(无报警), 1(有报警)。
	BOOL bTalkbackEnable;

	FILE * pMp3File1;
	FILE * pMp3File2;
	DWORD dwStartTime;
}TDevState;

static TSdkEventTermRegister g_TermList[MAX_TERM_COUNT];//设备列表
static TDevState g_TermState[MAX_TERM_COUNT];
static int g_nTermCnt = 0;
int devID;
static int g_nRecordTermIdx = -1;
static int g_nTalkTermIdx = -1;

static FILE * g_pPcmFileL = NULL;//原始数据
static FILE * g_pPcmFileR = NULL;
static int g_nPcmTotalLenL = 0;//原始数据长度
static int g_nPcmTotalLenR = 0;	

static const int g_nWaveHeaderSize = 38;
static const int g_nWaveFormatSize = 18;

static BOOL g_bExitSystem = FALSE;

//global变量
int is_connect;//是否已经连接标志
int is_alarm;//喧哗警报
int is_file;//是否已有音频文件打开
int pipo_fd;//管道ID

//条件编译，切换通信方式
#define PIPE 1
#define MQUEUE 2
#define COMMUNICATION_MODE PIPE

static LPCSTR GetStateText(enSdkDevState eState);
static LPCSTR GetTermType(enSdkDevType eTermType);

//设备初始化函数
int gdl703t_init();
int gdl703t_start(char routes);
int gdl703t_stop(int devid);
int getDB(char *r_l);//获取分贝值
int getDB_char(char r_l);
int get_is_connect();//获取连接状态


//回调函数
int CALLBACK OnTzlSdkCallback(enSdkCbType eCbType, LPVOID pParam, DWORD dwSize, int usr_data);



#endif